Random early packet discard (RED)

ABSTRACT

At telecommunications switches and routers, RED (random early packet discard) uses the queue depth to determine whether to keep or discard each packet as it arrives at a queue. This is done by determining a discard probability (P), which is dependent on the average depth of the queue, and comparing the discard probability to a random number. One way of performing the invention uses the summed discard probabilities, instead of counting the number of packets (count) and multiplying that by the current discard probability, as in the prior art. The resulting sum is compared to the random number for discard operation. The disclosure further describes a more accurate way of calculating average depth of a queue, especially when the queue encounters periods of idleness.

FIELD OF INVENTION

[0001] The invention resides in the field of congestion control in a communications switch or router. More particularly, the invention is directed to the problem of alleviating traffic congestion by selectively discarding packets of telecommunications traffic, based on the condition of a queue.

BACKGROUND OF INVENTION

[0002]FIG. 1 shows a simplified architecture of a communications switch 10 or a router. Packets 12 of traffic arrive at ingress queues and are switched by a switching fabric to egress queues before departing from an output port 14 of the switch. When the depth of packets in any queue exceeds a discard threshold (Dt) 16, packets arriving at that queue may be dropped in accordance with a tail drop procedure. That is, packets at the end of the queue are dropped until the queue depth (also called the queue occupancy) recedes below the discard threshold. A problem with this procedure, in the case of TCP connections, is that packets can be dropped from a single TCP connection because of the nature of the protocol.

[0003] Another type of discard procedure, which alleviates the aforementioned problem with TCP connections, is random early packet discard (RED for short). RED uses the queue depth (queue occupancy) to determine whether to keep or discard each packet as it arrives at the queue. This is done by determining a discard probability, which is dependent on the average depth of the queue (also called average queue depth or average queue occupancy), and comparing the discard probability to a random number. If the discard probability is greater than the random number the packet is discarded.

[0004]FIG. 2 shows a graph of an example discard probability function versus average queue depth. According to this function, the discard probability is zero until a minimum-threshold is reached, thereafter the discard probability increases linearly until a maximum threshold is reached. For average queue depths greater than the maximum threshold the discard probability is 100%.

[0005]FIG. 3 shows graphs of discard probability functions for a variation of RED, known as, weighted RED. In this case, there are three discard probability functions (green, yellow, and red) and each will result in a different discard probability for the same average queue depth. The particular discard probability function that is used for a packet depends on the drop precedence (colour) of the packet. The drop precedence (DP) is determined by examining the DiffServ Code Point (DSCP) field in the IP header of the packet. Packets that exceed agreements on their connections have their drop precedence (colour) changed by an IP policing procedure. As with the RED procedure, in weighted RED the determination to keep or discard a packet is made by comparing the discard probability of the packet to a random number, discarding the packet when the probability exceeds the number. Variations of this procedure include having more discard probability functions, and having different probability curves in accordance with a class of service (CoS) to which the packet belongs. The CoS of a packet is also determined by examining the DSCP field in the IP header.

[0006]FIG. 4 shows another example of weighted RED with the discard probability functions having shapes that are generally accepted to work well. The figure includes three graphs for three colours. For each colour, its function provides the discard probability that increases linearly from 0% to MAXP, as the average queue depth increases from its minimum threshold (MINth) to its maximum threshold (MAXth). Above MAXth, the discard probability is 100%. Different vendors and different drop precedence (colour) functions will have different values for MAXp, MINth, and MAXth shown in the figure. In the figure, MAXp, which is less than 100%, is same for all the colours. Discard probability functions having different shapes and curves are possible.

[0007] It is therefore summarized that whether a packet arriving to the RED system is queued or dropped depends on the current discard probability and the colour (relative priority) of the packet. Discard probability, in turn, depends on the average queue depth. These relations can be formalized as follows.

New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg))  (1)

P(colour)=F _(colour)(New N _(avg))  (2)

[0008] N_(avg) is the average queue depth, and 0<W<1 is a moving average weight that determines how closely the average follows the actual (current) queue depth, N_(cur). If W is small, the average will lag behind the actual queue depth; conversely, the average will follow closely the actual queue depth when W is large. P is a discard probability, different for every colour of a packet (colour∈{red, yellow, green}), and F(N_(avg)) is a linear discard probability function that returns values that depend on the colour and the average queue depth. FIGS. 2-4 give some example functions.

[0009] As previously mentioned, the determination of whether to discard or keep a packet is made by comparing the discard probability of the packet to a random number (RN). There are two common methods for selecting and comparing a random number, or random variable, to the discard probability. These methods are the geometric random variable (GRV) method and the uniform random variable (URV) method.

[0010]FIGS. 5 and 6 show a comparison of the results of the GRV and URV methods with a constant average queue depth. FIG. 5 is the GRV method and FIG. 6 is the URV method. In the figures the horizontal lines depict time and the small vertical lines depict packet discards. According to the geometric random variable (GRV) method, a new random number is selected for each packet arriving at a queue. If the discard probability for the packet exceeds the random number then the packet is discarded. As FIG. 5 shows, the resulting discards are randomly distributed in time. The URV method, on the other hand, selects a new random number only after a packet has been discarded. The URV method, therefore, counts the number of packets (count) since the last discard and multiplies the count by the discard probability. If the resulting product is greater than the random number then the packet is discarded, the count set to zero, and a new random number is generated. Otherwise the packet is accepted and the count is incremented.

[0011] UrV Algorithm: Initialize packet count=0; IF (packet count*P(colour))>RN), THEN { discard the packet; get a new RN; packet count=0; } Else { accept the packet; increment packet count (i.e., packet count=packet count+1) }

[0012] It has been shown that URV method gives a better performance than GRV method because it usually achieves a more uniform distribution of packet discards over time, as seen in FIG. 6. This is desirable because if too many packets are discarded consecutively and/or intervals between accepted packets are long, a global synchronization with several connections may occur, resulting in reduction of their windows at the same time.

[0013] Although the URV method provides the desirable result of uniformly distributing packet discards in time, it requires an additional multiply operation over the GRV method. This extra multiplication takes a significant amount of processing time. As an example, assume that a typical network processor has 56 cycles to process a 40-byte packet at 9.14 Gb/s (equivalent to OC-192) rate. Each multiplication operation takes 6 cycles to complete. This yields a total of 12 cycles for the multiplication part of the discard calculations. A problem with this approach is that, in the case of packets arriving at OC-192 rate, the URV discard procedure leaves only 44 cycles for the remainder of the discard processing, such as threshold checking. At these rates, every cycle is precious and saving them is important. The present invention provides novel ways to perform RED more efficiently, requiring less processing power and/or time, making it more suitable for high-speed applications.

[0014] Furthermore, to perform the RED algorithm, discard probability, P(colour), which depends on average queue depth, N_(avg), must be calculated by using formulae (1) and (2). There are several ways of calculating formulae (1) and (2). Two common variations are described here, i.e., “background method” and “arrival method”. In the first method, a background process is invoked every T seconds. This process calculates average queue depth and discard probability using formulae (1) and (2) respectively. The obtained values are then used to determine a fate of every packet that arrives to the system during the next T seconds. After that time, the background process is called again, the current queue depth is fetched, and new average queue depth and discard probability are computed. In the second method, on the other hand, average queue depth and discard probability are not calculated periodically but every time a packet arrives to the system. Again, formulae (1) and (2) above are used for the calculations and the packet is either accepted or discarded based on the calculated value of discard probability. Whichever method is used, either URV or GRV procedure described above can be employed to perform accept/discard action.

[0015] When using “the arrival method”, however, there may be an additional problem in calculating average queue depth after idle times, i.e., when the queue is empty. Referring to FIG. 7, which is a graph of actual (instantaneous) queue depth 70 compared to average queue depth 72. According to the procedure for calculating average queue depth when the queue is empty, the calculated average queue depth can incorrectly remain constant as shown by solid line 74 when in fact the correct average queue depth shown by dotted line 76 is decreasing.

[0016] This is explained as follows:

[0017] In known procedures of RED, when the queue goes empty, a timestamp is taken. When the next packet arrives, calculation of the average queue depth is made. When the queue is empty, formula (3) below, instead of formula (1) mentioned above, is used to calculate the average queue depth;

New N _(avg)=Previous N _(avg)×function(idle time, W)  (3)

[0018] The idle time is found by subtracting the current time from the queue empty timestamp. If the idle time is very small, the “function” given in formula (3) will be essentially equal to 1. If this occurs, the N_(avg) does not change. Then the packet is transmitted, the queue goes empty, and a short time later another packet arrives. Again idle time is very small and N_(avg) does not change. This can continue indefinitely. This error in the determination of the average queue depth, which could lead to needless discard of packets, is undesirable.

[0019] It is therefore apparent that improved techniques of discarding packets are desired. The techniques should require less processing power and/or time.

[0020] A further improvement in accuracy of calculating the average queue depth is also required for better performance of the random early packet discard operation.

SUMMARY OF INVENTION

[0021] The invention relates to the problem of alleviating traffic congestion in a communications switch or router. More particularly, the invention relates to a technique which requires less processing power and/or time.

[0022] In accordance with one aspect, the invention is directed to an improved technique of selectively discarding packets of traffic depending on the fill level, or depth, of queues in the communications switch.

[0023] In accordance with another aspect, the invention provides a method of obtaining discards uniformly distributed in time like the URV procedure but with less processing cycles, making it more suitable for OC-192 applications.

[0024] According to yet another aspect, the invention uses the summed discard probabilities, instead of counting the number of packets (count) and multiplying that by the current discard probability, as in the prior art. The resulting sum is compared to the random number for discard operation.

[0025] In accordance with yet another aspect, the invention provides a more accurate way of calculating average depth of a queue, especially when the queue encounters periods of idleness.

[0026] A further aspect of the invention therefore calls for a novel RED technique based on a more accurate average queue depth calculation, which results in improved packet discard operation with less processing power than required in the known techniques.

[0027] According to one specific aspect, the invention relates to a method of controlling a queue of a communications system. The method includes steps of deciding an accept/discard operation on a packet arriving at the queue, based on comparison between a discard probability sum for the packet and a random variable, calculating a discard probability for the packet, using an average depth of the queue, and generating a new discard probability sum for a next packet arriving at the queue, by summing the discard probability sum and the calculated discard probability.

[0028] In accordance with another aspect, the invention resides in the field of a random early packet discard procedure in a telecommunications system. The invention is directed to a method of calculating an average depth of a queue when a packet arrives at the queue. The method includes steps of measuring a current queue depth, N_(cur), retaining a previous average queue depth, Previous N_(avg), and monitoring whether or not the queue is empty. The method further includes a step of updating the average queue depth, New N_(avg), by the following formulae;

[0029] if the queue is not empty,

New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg));

[0030] if the queue is empty,

New N _(avg)=Previous N _(avg)×function(idle time, W), and

[0031] if the queue is empty and also New N_(avg)=Previous N_(avg),

New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg));

[0032] where W is a running weight between 0 and 1, and the function is a function that returns values based on the idle time of the queue and W.

[0033] According to another specific aspect, the invention is directed to a mechanism for controlling a queue of a communications system. The mechanism comprises a receiver for receiving and sending a packet to a queue for storage, and discard probability calculation module for calculating the discard probability sum which is the summation of discard probabilities of all packets that have arrived at the queue since a packet was last discarded from the queue. The mechanism further includes a random number generator for generating a random number when instructed, and discard module for discarding the just arrived packet from the queue if the discard probability sum is greater than the random number, and instructing the discard probability calculation module to set the discard probability sum to zero and to generate another random number to replace the aforementioned random number.

BRIEF DESCRIPTION OF DRAWINGS

[0034]FIG. 1 is a schematic illustration of a packet switch or router.

[0035]FIG. 2 is a graph of an example discard probability (Pb) function versus average queue depth.

[0036]FIG. 3 shows graphs of example discard probability functions for another discard procedure known as weighted RED.

[0037]FIG. 4 shows a graph of a discard probability function having a shape that is generally accepted to work well.

[0038]FIGS. 5 and 6 show the results of the GRV (geometric random variable) and URV (uniform random variable) methods with a constant average queue depth.

[0039]FIG. 7 are graphs of actual queue depth and average queue depth calculated by a known method, illustrating that improvements are needed.

[0040]FIG. 8 is a flowchart of the algorithm in accordance with one embodiment of the invention.

[0041]FIG. 9 is a schematic illustration of the discard mechanism according to one embodiment of the invention.

DETAILED DESCRIPTION OF EMBODIMENTS OF INVENTION

[0042] According to an embodiment of the invention, the discard probabilities are summed for each colour, instead of counting the number of packets (count) and multiplying that by the current discard probability P(colour), as in the prior art. The resulting sum (discard probability sum or P_(sum)(colour)) is compared to the random number (RN). If P_(sum)(colour) is greater than RN then the packet is discarded and P_(sum)(colour) is set to zero, otherwise the packet is accepted and the new discard probability P(colour) is added to P_(sum)(colour) (i.e., P_(sum)(colour)=P_(sum)(colour)+P(colour)). The result is packet discards for each colour that are uniformly distributed in time similar to the prior art URV method, but requires 50% less processing cycles to implement. This improvement in efficiency allows uniformly distributed packet discards to be achieved on OC-192 rate connections.

[0043] A new discard algorithm in accordance with one embodiment is therefore as follows: Initialize=0 IF (P_(sum)(colour)>RN) then { discard packet; P_(sum)(colour)=0; get a new RN; } Else { accept packet; P_(sum)(colour)=P_(sum)(colour)+P(colour) }

[0044]FIG. 8 is a flowchart of the above algorithm.

[0045]FIG. 9 is a schematic illustration of a discard mechanism according to the above-described embodiment of the invention. The figure only shows one queue associated with a variety of modules. It should be noted that a plurality of queues are in a switch or a router and they may share some or all modules. In the figure, a receiver 80 receives a packet and sends over to the queue 82 for storage from which a transmitter 84 transports a stored packet downstream. The receiver checks the drop precedence (colour) of the packet, if there are more than one level of precedence. A discard probability calculation module 86 continuously monitors the queue depth. It also calculates average queue depth and determines discard probability for the just arrived packet and the discard probability sum. The discard probability calculation module further makes a decision of accept/discard the packet in response to comparison between the discard probability sum for the colour of the packet and a random number obtained from random number generator 88. Discard module 90 drops off the packet from the tail of the queue when instructed by the discard probability-calculation module. The discard probability calculation module 86 includes a variety of elements such as processor, sum operator and a memory. The sum operator produces summation of the newly calculated discard probability P(colour) and previous P_(sum)(colour) (i.e., P_(sum)(colour)=P_(sum)(colour)+P(colour)) to produce a new P_(sum)(colour). This operation is more efficient than a multiplication operation of the prior art mechanism.

[0046] The invention provides a further improvement in the “arrival method”, resulting in a better accuracy of calculating the average queue depth (N_(avg)) of a queue when the queue encounters short idle periods. As previously mentioned by referring to FIG. 7, the prior art “arrival” method of making such calculations can lead to an incorrectly calculated average queue depth when an increasing queue depth is followed by short periods of queue emptiness. This will result in unnecessary discards in RED. The invention provides new ways of calculating average queue depth when the queue is empty to ensure a better performance of RED. Generally speaking, according to the invention, when the queue is empty and the new average equals the previous average, a formula for calculating average queue depth for a non-empty queue depth will be used.

[0047] In accordance with an embodiment of the invention, the average queue depth N_(avg) when the queue is empty is calculated using two separate formulae. When the queue is empty, formula (3) above is used but when the queue is empty and also “New N_(avg)=Previous N_(avg)”, then formula (1) is used.

[0048] In accordance with an embodiment, the invention uses the following logic: IF (the queue is empty){  use formula (3): New N_(avg)=Previous N_(avg)×function(idle time, W)  IF (New N_(avg)==Previous N_(avg)){   use formula (1):New N_(avg)=Previous N_(avg)+W×(N_(cur)−Previous N_(avg))  } } Else{  use formula (1): New N_(avg)=Previous N_(avg)+W×(N_(cur)−Previous N_(avg)) }

[0049] In accordance with an embodiment, in formula (1), weight W can take a form of ½^(M), where M is between 0 and 15.

[0050] In accordance with a further embodiment when the discard probability function is that shown in FIG. 4, the discard probability, P for each colour, can be expressed as below:

P(colour)=MAXp{New N _(avg)(colour)−MINth(colour)}/{MAXth(colour)−MINth(colour)}  (4)

[0051] The invention provides a more efficient technique of performing weighted random early discard (RED) of packets, thereby enabling such actions to be performed on OC192 rate connections. The improved technique provides a distribution of packet discards that is uniformly distributed over time. This type is desirable because it is less likely to effect any one connection, especially so in the case of TCP connections.

[0052] The invention also provides a more accurate technique of calculating the average queue depth for periods of idle time, thereby preventing unnecessary discards that could otherwise result, as in the case of the prior art method.

[0053] The capability of alleviating traffic congestion in a switch is necessary in order to guarantee service quality to customers of a network. It is desirable to alleviate the congestion by discarding packets of traffic in a manner such that any particular connection on a congested port of the switch is not unduly affected. The invention provides this capability in a manner that is more processing efficient than prior art methods (e.g., weighted RED). This efficiency enables the invention to be performed on OC192 rate connections, which is not possible with prior art methods executed with currently available processors. Therefore, the invention has immediate commercial value for OC192 applications because it provides a capability that is not currently available. Furthermore, due to its higher processing efficiency, the invention should continue to be valuable to our competitors as data rates increase. 

What is claimed as an invention is:
 1. A method of controlling a queue of a communications system, comprising steps of: (a) deciding an accept/discard operation on a packet arriving at the queue, based on comparison between a discard probability sum for the packet and a random variable; (b) calculating a discard probability for the packet, using an average depth of the queue, and (c) generating a new discard probability sum for a next packet arriving at the queue, by summing the discard probability sum and the calculated discard probability.
 2. The method according to claim 1, further comprising a step of: (d) accepting a packet arriving at the queue if a discard probability sum for the packet is smaller than or equal to a random variable.
 3. The method according to claim 1, further comprising steps of: (e) discarding the packet arriving at the queue if the discard probability sum for the packet is larger than the random variable; (f) setting the discard probability sum to zero, and (g) generating another random variable to replace the aforementioned random variable.
 4. The method according to claim 2, further comprising steps of: repeating steps (a) to (d) for each packet arriving at the queue; discarding a packet arriving at the queue the most recently, if the discard probability sum for the most recent packet is larger than the random variable; setting the discard probability sum to zero; generating another random variable to replace the aforementioned random variable, and repeating steps (a) to (d) for further packets arriving at the queue.
 5. The method according to claim 4, further comprising steps of: calculating the average depth of the queue every time a new packet arrives at the queue, and calculating the discard probability for the newly arrived packet based on the calculated average depth of the queue.
 6. The method according to claim 5 wherein the step of calculating the average depth of the queue comprises further steps of: measuring a current queue depth, N_(cur); retaining a previous average queue depth, Previous N_(avg); monitoring whether or not the queue is empty, and updating the average queue depth, New N_(avg), by the following formulae; if the queue is not empty, New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg)); if the queue is empty, New N _(avg)=Previous N _(avg)×function(idle time, W), and if the queue is empty and also New N_(avg)=Previous N_(avg); New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg)); where W is a running weight between 0 and
 1. 7. The method according to claim 2 wherein the packet has a drop precedence of a plurality of levels expressed in colours and each colour has its discard probability and discard probability sum, the method further comprising steps of: checking the colour of the packet arriving at the queue, and accepting or discarding the packet based on discard probability sum for the colour.
 8. The method according to claim 3 wherein the packet has a drop precedence of a plurality of levels expressed in colours and each colour has its discard probability and discard probability sum, the method further comprising steps of: checking the colour of the packet arriving at the queue, and accepting or discarding the packet based on discard probability sum for the colour.
 9. The method according to claim 4, further comprising steps of: calculating a discard probability for the colour, using an average depth of the queue, and generating a new discard probability sum for a next packet of the colour arriving at the queue, by summing the discard probability sum and the calculated discard probability for the colour.
 10. The method according to claim 5, further comprising steps of: calculating a discard probability for the colour, using an average depth of the queue, and generating a new discard probability sum for a next packet of the colour arriving at the queue, by summing the discard probability sum and the calculated discard probability for the colour.
 11. The method according to claim 6, further comprising steps of: calculating a discard probability for the colour, using an average depth of the queue, and generating a new discard probability sum for a next packet of the colour arriving at the queue, by summing the discard probability sum and the calculated discard probability for the colour.
 12. In performing a random early packet discard procedure in a telecommunications system, a method of calculating an average depth of a queue when a packet arrives thereat, comprising steps of: measuring a current queue depth, N_(cur); retaining a previous average queue depth, Previous N_(avg); monitoring whether or not the queue is empty, and updating the average queue depth, New N_(avg), by the following formulae; if the queue is not empty, New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg)); if the queue is empty, New N _(avg)=Previous N _(avg)×function(idle time, W), and if the queue is empty and also New N_(avg)=Previous N_(avg), New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg)); where W is a running weight between 0 and 1, and the function is a function that returns values based on the idle time of the queue and W.
 13. The method according to claim 12, wherein W is ½^(M) and M is an integer between 0 and
 15. 14. The method of claim 12, further comprising steps of: deciding an accept/discard operation on a packet arriving at the queue, based on comparison between a discard probability sum for the packet and a random variable; calculating a discard probability for the packet, using an average depth of the queue, and generating a new discard probability sum for a next packet arriving at the queue, by summing the discard probability sum and the calculated discard probability.
 15. The method according to claim 14, further comprising steps of: accepting each packet arriving at the queue if a discard probability sum for the packet is smaller than or equal to a random variable. discarding a packet arriving at the queue the most recently, if the discard probability sum for the most recent packet is larger than the random variable; setting the discard probability sum to zero; generating another random variable to replace the aforementioned random variable, and deciding an accept/discard operation on further packets arriving at the queue.
 16. The method according to claim 15 wherein packets arriving at the queue have a drop precedence of a plurality of levels expressed in colours and each colour has its discard probability and discard probability sum, the method further comprising steps of: checking the colour of each packet arriving at the queue, and accepting or discarding the packet based on discard probability sum for the colour.
 17. A mechanism for controlling a queue of a communications system, comprising: a receiver for receiving and sending a packet to a queue for storage; discard probability calculation module for calculating the discard probability sum which is the summation of discard probabilities of all packets that have arrived at the queue since a packet was last discarded from the queue; a random number generator for generating a random number when instructed, and discard module for discarding the just arrived packet from the queue if the discard probability sum is greater than the random number, and instructing the discard probability calculation module to set the discard probability sum to zero and to generate another random number to replace the aforementioned random number.
 18. The mechanism according to claim 17, further comprising: a sum operator for producing a new discard probability sum by a summation of a newly calculated discard probability for the just arrived packet and a previous discard probability sum.
 19. The mechanism according to claim 18, further comprising: a processor for obtaining an average depth of the queue by using following equations, if the queue is not empty, New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg)); if the queue is empty, New N _(avg)=Previous N _(avg)×function(idle time, W), and if the queue is empty and also New N_(avg)=Previous N_(avg), New N _(avg)=Previous N _(avg) +W×(N _(cur)−Previous N _(avg)); where N_(cur) is a current queue depth, Previous N_(avg) is a previous average queue depth, New N_(avg) is the average queue depth, W is a running weight between 0 and 1, and the function is a function that returns values based on the idle time of the queue and W.
 20. The mechanism according to claim 18, wherein the receiver further comprises means for checking drop precedence of the just arrived packet. 